Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sokol_gfx.h: add explicit depth / stencil formats #1124

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kcbanner
Copy link
Contributor

@kcbanner kcbanner commented Oct 15, 2024

Closes #1122.

@kcbanner kcbanner marked this pull request as ready for review October 17, 2024 02:44
case SG_PIXELFORMAT_RGBA32F: return DXGI_FORMAT_R32G32B32A32_FLOAT;
case SG_PIXELFORMAT_DEPTH: return DXGI_FORMAT_R32_TYPELESS;
case SG_PIXELFORMAT_DEPTH_STENCIL: return DXGI_FORMAT_R24G8_TYPELESS;
case SG_PIXELFORMAT_DEPTH24PLUS: return DXGI_FORMAT_R24G8_TYPELESS;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't find a DirectX format that mapped to a 24-bit depth buffer with no stencil - so SG_PIXELFORMAT_DEPTH24PLUS is equivalent to SG_PIXELFORMAT_DEPTH24PLUS_STENCIL8. Is this the correct approach, or should this format not be supported at all on DirectX?

@@ -11693,6 +11768,10 @@ _SOKOL_PRIVATE MTLPixelFormat _sg_mtl_pixel_format(sg_pixel_format fmt) {
case SG_PIXELFORMAT_RGBA32F: return MTLPixelFormatRGBA32Float;
case SG_PIXELFORMAT_DEPTH: return MTLPixelFormatDepth32Float;
case SG_PIXELFORMAT_DEPTH_STENCIL: return MTLPixelFormatDepth32Float_Stencil8;
case SG_PIXELFORMAT_DEPTH24PLUS: return MTLPixelFormatDepth24Unorm_Stencil8;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is similar to the problem on DirectX, there is no format that maps directly to just a 24-bit depth buffer.

@kcbanner kcbanner changed the title sokol_gfx.h: add SG_PIXELFORMAT_DEPTH32F_STENCIL8 sokol_gfx.h: add explicit depth / stencil formats Oct 17, 2024
@kcbanner
Copy link
Contributor Author

Moving this into review now that the other formats have been added. See the comments above - I'm not sure how to handle SG_PIXELFORMAT_DEPTH24PLUS on Metal and DirectX.

@floooh
Copy link
Owner

floooh commented Oct 18, 2024

Sorry, didn't get around yet to look into the PR. I'll try to make some time over the weekend :)

I'll most like need to do a little research first for the other 3D backends.

There's also always the option to split support for the different backends over multiple smaller PRs, might speed things up a bit :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

gfx proposal: support for floating point depth buffer with a stencil component
2 participants